package com.kalix.vote.management.biz;

import com.kalix.framework.core.impl.biz.ShiroGenericBizServiceImpl;
import com.kalix.vote.management.api.biz.IVoteConfigBeanService;
import com.kalix.vote.management.api.dao.IVoteConfigBeanDao;
import com.kalix.vote.management.entities.VoteConfigBean;

import java.util.List;

public class VoteConfigBeanServiceImpl extends ShiroGenericBizServiceImpl<IVoteConfigBeanDao, VoteConfigBean> implements IVoteConfigBeanService {

    @Override
    public List<VoteConfigBean> getAllVoteConfigInfo() {
        return dao.getAll();
    }

    @Override
    public VoteConfigBean getVoteConfigByType(String voteType) {
        List<VoteConfigBean> voteConfigs = dao.findByNativeSql("select * from vote_config where votetype = '" + voteType + "'", VoteConfigBean.class);
        if (voteConfigs == null || voteConfigs.isEmpty()) {
            return null;
        }
        return voteConfigs.get(0);
    }
}
